package com.saasitems.admin.service;

import com.saasitems.admin.dao.MattsMapper;
import com.saasitems.admin.dao.TemplateInfoMapper;
import com.saasitems.admin.model.TemplateInfo;
import com.saasitems.admin.model.TemplateInfoExample;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by apple on 17/6/20.
 */
@Service
public class TemplateInfoService {
    @Autowired
    private TemplateInfoMapper templateInfoMapper;

    public TemplateInfo getInfo(String templName) {
        TemplateInfoExample ex = new TemplateInfoExample();
        TemplateInfoExample.Criteria c = ex.createCriteria();

        if (StringUtils.isBlank(templName)) {
            return new TemplateInfo();
        }
        c.andTemplateEqualTo(templName);
        List<TemplateInfo> ls = this.templateInfoMapper.selectByExample(ex);
        if (ls == null || ls.isEmpty()) {
            return new TemplateInfo();
        }
        return ls.get(0);
    }
}
